<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-content">
                <div class="row">
                    <form action="<?=url('hotel.room/create')?>" id="form-create" method="post" class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>酒店：</label>
                            <div class="col-sm-6">
                                <input id="hotelname" type="text" disabled style="background-color: transparent;" value="<?=empty($hotel->hotel_name) ? '' : $hotel->hotel_name ?>" placeholder="请单击选择酒店"  class="form-control"/>
                                <input type="hidden" value="<?php empty($hotel->hotel_id) ? '' : $hotel->hotel_id ?>" name="hotel_id" id="hotel_id">
                            </div>
                            <div class="col-sm-3">
                                <button type="button" mini="load" w="95%" h="95%" href="<?=url('miniapp/hotel.hotel/select')?>" class="btn btn-w-m btn-info">选择酒店</button>
                            </div>
                            <script>
                                function seleHotel(hotel_name,hotel_id){
                                    layer.closeAll();
                                    layer.msg('操作成功！');
                                    $("#hotelname").val(hotel_name);
                                    $("#hotel_id").val(hotel_id);
                                }
                            </script>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>房屋类型：</label>
                            <div class="col-sm-9">
                                  <select name="room_type" class="form-control">
                                      <?php foreach(config('dataattr.hotelroomtypenames') as $key=>$val) { ?>
                                      <option class="form-control" value="<?=$key?>"><?=$val?></option>
                                      <?php } ?>
                                  </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>房间名称：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->title)?$detail->title:''?>" placeholder="请输入房间名称 如:大床房" id="title" name="title" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>面积：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->area)?$detail->area:''?>" placeholder="请输入房屋的面积 如：100 单位平米" id="area" name="area" class="form-control"/>
                            </div>
                        </div>
                        <link rel="stylesheet" type="text/css" href="/public/common/webuploader-0.1.5/webuploader.css">
                        <script type="text/javascript" src="/public/common/webuploader-0.1.5/webuploader.js"></script>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>图片：</label>
                            <div class="col-sm-9 ">

                                <div id="uploader-demo" style="max-width: 300px">
                                    <!--用来存放item-->
                                    <div id="photoList" class="uploader-list">
                                        <?php if(isset($detail['photo'])){?>
                                        <div class="file-item thumbnail"><img width="110"
                                                                              src="/attachs/uploads/<?=$detail['photo']?>"><input
                                                type="hidden" value="<?=$detail['photo']?>" name="photo" id="photo">
                                        </div>
                                        <?php }?>
                                    </div>
                                    <div id="photoPicker">选择图片</div>
                                </div>
                            </div>
                        </div>
                        <script>
                            var uploaderphoto = WebUploader.create({
                                auto: true,
                                swf: '/public/admin/Widget/webuploader-0.1.5/Uploader.swf',
                                server: '<?=url("upload.upload/index",['mdl'=>"room_photo"])?>',
                                pick: '#photoPicker',
                                resize: false,
                                duplicate: true
                            });

                            $(document).on('click', '.file-item', function () {
                                $(this).remove();
                            });
                            // 当有文件添加进来的时候
                            uploaderphoto.on('fileQueued', function (file) {
                                var $li = $(
                                        '<div id="' + file.id + '" class="file-item thumbnail">' +
                                        '<img>' +
                                        '<input type="hidden" value="" name="photo" id="photo">' +
                                        '<div class="info">' + file.name + '</div>' +
                                        '</div>'
                                    ),
                                    $img = $li.find('img');
                                // $list为容器jQuery实例
                                $("#photoList").html($li);

                                // 创建缩略图
                                // 如果为非图片文件，可以不用调用此方法。
                                // thumbnailWidth x thumbnailHeight 为 100 x 100
                                uploaderphoto.makeThumb(file, function (error, src) {
                                    if (error) {
                                        $img.replaceWith('<span>不能预览</span>');
                                        return;
                                    }

                                    $img.attr('src', src);
                                }, 100, 100);
                            });
                            // 文件上传过程中创建进度条实时显示。
                            uploaderphoto.on('uploadProgress', function (file, percentage) {
                                var $li = $('#' + file.id),
                                    $percent = $li.find('.progress span');

                                // 避免重复创建
                                if (!$percent.length) {
                                    $percent = $('<p class="progress"><span></span></p>')
                                        .appendTo($li)
                                        .find('span');
                                }

                                $percent.css('width', percentage * 100 + '%');
                            });

                            // 文件上传成功，给item添加成功class, 用样式标记上传成功。
                            uploaderphoto.on('uploadSuccess', function (file, response) {
                                $('#' + file.id).addClass('upload-state-done');
                                $("#photo").val(response._raw);
                            });

                            // 文件上传失败，显示上传出错。
                            uploaderphoto.on('uploadError', function (file) {
                                var $li = $('#' + file.id),
                                    $error = $li.find('div.error');

                                // 避免重复创建
                                if (!$error.length) {
                                    $error = $('<div class="error"></div>').appendTo($li);
                                }

                                $error.text('上传失败');
                            });

                            // 完成上传完了，成功或者失败，先删除进度条。
                            uploaderphoto.on('uploadComplete', function (file) {
                                $('#' + file.id).find('.progress').remove();
                            });

                        </script>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>日常价格：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->price)?$detail->price:''?>" placeholder="请填写该房间的日常价格 如：998 单位元"
                                       id="price" name="price" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>床的类型：</label>
                            <div class="col-sm-9">
                                 <select name="bed_type" class="form-control">
                                        <?php foreach(config('dataattr.hotelbedtype') as $key=>$val) { ?>
                                            <option class="form-control" value="<?=$key?>"><?=$val?></option>
                                        <?php } ?>
                                 </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>床宽：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->bed_width)?$detail->bed_width:''?>" placeholder="请填写床的宽度 如：1.8 单位米" id="bed_width" name="bed_width" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>床长：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->bed_logn)?$detail->bed_logn:''?>" placeholder="请填床的长度 如：0.5 单位米" id="bed_logn" name="bed_logn" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>床的数量：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->bed_num)?$detail->bed_num:''?>" placeholder="请填写床的数量：3 单位张" id="bed_num" name="bed_num" class="form-control"/>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>单日最大预定：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->day_num)?$detail->day_num:''?>"
                                       placeholder="该房间单日最大预定的次数 如：1 说明只能预定一次 预定之后" id="day_num" name="day_num" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>是否上架：</label>
                            <div class="col-sm-9">
                                <div class="radio i-checks">
                                    <label>
                                        <input name="is_online" id="is_online" value="1"
                                               type="radio" <?php if(isset($detail->is_online)&&
                                        $detail->is_online==1){?>checked="checked"<?php }?> > <i></i> 是</label>
                                    <label>
                                        <input name="is_online" id="is_online" value="0"
                                               type="radio" <?php if(isset($detail->is_online)&&
                                        $detail->is_online==0){?>checked="checked"<?php }?> > <i></i> 否</label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>是否有WIFI：</label>
                            <div class="col-sm-9">
                                <div class="radio i-checks">
                                    <label>
                                        <input name="is_wifi" id="is_wifi" value="1"
                                               type="radio" <?php if(isset($detail->is_wifi)&&
                                        $detail->is_wifi==1){?>checked="checked"<?php }?> > <i></i> 是</label>
                                    <label>
                                        <input name="is_wifi" id="is_wifi" value="0"
                                               type="radio" <?php if(isset($detail->is_wifi)&&
                                        $detail->is_wifi==0){?>checked="checked"<?php }?> > <i></i> 否</label>
                                </div>
                            </div>
                        </div>
                        <div class="clearfix form-actions">
                            <div class="col-md-offset-3 col-md-9">
                                <button mini="submit" for="form-create" class="btn btn-info" type="button">
                                    <i class="ace-icon fa fa-check bigger-110"></i>
                                    保存
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>